home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / virtltxt / inimaint.bas < prev    next >
BASIC Source File  |  1994-01-21  |  23KB  |  695 lines

  1. 'INIMAINT.BAS: VBC Version
  2.  
  3. Sub ChangeFileList (filestr$)
  4.  
  5.     IniFileName$ = "VIRTEXT.INI"  'name of ini file
  6.     AppName$ = "Display"          'Name of application or section heading
  7.     KeyName$ = "File1"            'Keyword or variable name"
  8.     DefaultStr$ = "NONE"
  9.     Numeric% = 0                  'Tell it we are looking for a string
  10.     ReadIni AppName$, KeyName$, nDefault, DefaultStr$, ReturnStr$, Numeric%, IniFileName$
  11.  
  12. '***********************************************************
  13. '   If NONE is returned the file does not exist - create it
  14. '***********************************************************
  15.  
  16.     If ReturnStr$ = "NONE" Then
  17.     SaveFileINIFile
  18.     SaveOptions
  19.     End If
  20.  
  21. '***********************************************************
  22. '*  Get the files that are saved we'll move them down one
  23. '***********************************************************
  24.  
  25. For X = 1 To 5
  26.  
  27.     Select Case X
  28.     Case 1
  29.     KeyName$ = "File1"         'Keyword or variable name"
  30.     Case 2
  31.     KeyName$ = "File2"         'Keyword or variable name"
  32.     Case 3
  33.     KeyName$ = "File3"         'Keyword or variable name"
  34.     Case 4
  35.     KeyName$ = "File4"         'Keyword or variable name"
  36.     Case 5
  37.     KeyName$ = "File5"         'Keyword or variable name"
  38.     End Select
  39.  
  40.  
  41.     DefaultStr$ = " "          'Default string (for String variables)
  42.     Numeric% = 0   'Tell it we are looking for a string
  43.     ReadIni AppName$, KeyName$, nDefault, DefaultStr$, ReturnStr$, Numeric%, IniFileName$
  44.  
  45.     Select Case X
  46.     Case 1
  47.     File2$ = ReturnStr$          'Keyword or variable name"
  48.     Case 2
  49.     File3$ = ReturnStr$          'Keyword or variable name"
  50.     Case 3
  51.     File4$ = ReturnStr$          'Keyword or variable name"
  52.     Case 4
  53.     File5$ = ReturnStr$          'Keyword or variable name"
  54.     Case 5
  55.     File6$ = ReturnStr$          'Keyword or variable name"
  56.     End Select
  57.  
  58.     If Trim$(ReturnStr$) = Trim$(FullFilePath) Then Exit Sub
  59.  
  60. Next
  61.  
  62. ' Save the file name that was just selected
  63.  
  64. For X = 1 To 5
  65.  
  66.     IniFileName$ = "VIRTEXT.INI"    'name of ini file
  67.     AppName$ = "Display"           'Name of application or section heading
  68.  
  69.     Select Case X
  70.     Case 1
  71.     KeyName$ = "File1"             'Keyword or variable name"
  72.     NewVal$ = FullFilePath
  73.     Case 2
  74.     KeyName$ = "File2"             'Keyword or variable name"
  75.     NewVal$ = File2$
  76.     Case 3
  77.     KeyName$ = "File3"             'Keyword or variable name"
  78.     NewVal$ = File3$
  79.     Case 4
  80.     KeyName$ = "File4"             'Keyword or variable name"
  81.     NewVal$ = File4$
  82.     Case 5
  83.     KeyName$ = "File5"             'Keyword or variable name"
  84.     NewVal$ = File5$
  85.     End Select
  86.  
  87.     SaveIni AppName$, IniFileName$, KeyName$, NewVal$
  88.  
  89.     If Trim$(NewVal$) <> "" Then
  90.     VirtualText.zBar1.Visible = True
  91.     VirtualText.mnuFileList(X).Visible = True
  92.     VirtualText.mnuFileList(X).Caption = "&" + Trim$(Str$(X)) + " " + NewVal$
  93.     End If
  94.  
  95. Next
  96.  
  97. End Sub
  98.  
  99. Sub ReadIni (AppName$, KeyName$, nDefault, DefaultStr$, ReturnStr$, Numeric%, IniFileName$)
  100.  
  101. ' Read data from Private Profile (.ini) File
  102.  
  103. If Numeric% Then    'we are looking for integer input
  104.     Numeric% = GetPrivateProfileInt(AppName$, KeyName$, nDefault, IniFileName$)
  105. Else
  106.     Dim RetStr As String * 255 'Create an empty string to be filled
  107.     nSize% = 255               'uncertain - possibly length of fill string
  108.     lenRetString% = GetPrivateProfileString(AppName$, KeyName$, DefaultStr$, RetStr$, nSize%, IniFileName$)
  109.     ReturnStr$ = Left$(RetStr$, lenRetString%)
  110.  
  111. End If
  112.  
  113. End Sub
  114.  
  115. Sub ReadINIFile ()
  116.  
  117.     IniFileName$ = "VIRTEXT.INI"        'name of ini file
  118.     AppName$ = "Display"         'Name of application or section heading
  119.     KeyName$ = "File1"         'Keyword or variable name"
  120.     DefaultStr$ = "NONE"
  121.     Numeric% = 0   'Tell it we are looking for a string
  122.     ReadIni AppName$, KeyName$, nDefault, DefaultStr$, ReturnStr$, Numeric%, IniFileName$
  123. '***********************************************************
  124. '   If NONE is returned the file does not exist - create it
  125. '***********************************************************
  126.  
  127.     If ReturnStr$ = "NONE" Then
  128.         ' Initial Default
  129.         optPrinterFont = "Courier New"
  130.         optPrinterFontSize = Val("8.25")
  131.         optPrinterFontBold = False
  132.         optPrinterFontItalic = False
  133.     
  134.         SaveFileINIFile
  135.         SaveOptions
  136.         SaveFormPosition
  137.     End If
  138.  
  139. '***********************************************************
  140. '*  Get the files that are saved
  141. '***********************************************************
  142.  
  143. For X = 1 To 5
  144.  
  145.     Select Case X
  146.     Case 1
  147.     KeyName$ = "File1"         'Keyword or variable name"
  148.     Case 2
  149.     KeyName$ = "File2"         'Keyword or variable name"
  150.     Case 3
  151.     KeyName$ = "File3"         'Keyword or variable name"
  152.     Case 4
  153.     KeyName$ = "File4"         'Keyword or variable name"
  154.     Case 5
  155.     KeyName$ = "File5"         'Keyword or variable name"
  156.     End Select
  157.  
  158.  
  159.     DefaultStr$ = " "          'Default string (for String variables)
  160.     Numeric% = 0   'Tell it we are looking for a string
  161.     ReadIni AppName$, KeyName$, nDefault, DefaultStr$, ReturnStr$, Numeric%, IniFileName$
  162.  
  163.     If Trim$(ReturnStr$) <> "" Then
  164.     VirtualText.zBar1.Visible = True
  165.     VirtualText.mnuFileList(X).Visible = True
  166.     VirtualText.mnuFileList(X).Caption = "&" + Trim$(Str$(X)) + " " + ReturnStr$
  167.     End If
  168. Next
  169.  
  170.  
  171. '***********************************************************
  172. '*  Get the other information about the display
  173. '***********************************************************
  174.  
  175. '*******************************
  176. '   Read the Background color
  177. '*******************************
  178.     DefaultStr$ = " "          'Default string (for String variables)
  179.     Numeric% = 0   'Tell it we are looking for a string
  180.     KeyName$ = "BackColor"       'Keyword or variable name
  181.     ReadIni AppName$, KeyName$, nDefault, DefaultStr$, ReturnStr$, Numeric%, IniFileName$
  182.  
  183.     For X = 1 To NumArrays
  184.     VirtualText.TextArray(X).BackColor = Val(ReturnStr$)
  185.     Next
  186.  
  187. '*******************************
  188. '   Read the Foreground color
  189. '*******************************
  190.     DefaultStr$ = " "          'Default string (for String variables)
  191.     Numeric% = 0   'Tell it we are looking for a string
  192.     KeyName$ = "ForeColor"       'Keyword or variable name
  193.     ReadIni AppName$, KeyName$, nDefault, DefaultStr$, ReturnStr$, Numeric%, IniFileName$
  194.  
  195.     For X = 1 To NumArrays
  196.     VirtualText.TextArray(X).ForeColor = Val(ReturnStr$)
  197.     Next
  198.  
  199.  
  200. '*******************************
  201. '   Read the FontName Setting
  202. '*******************************
  203.     DefaultStr$ = " "          'Default string (for String variables)
  204.     Numeric% = 0   'Tell it we are looking for a string
  205.     KeyName$ = "FontName"    'Keyword or variable name
  206.     ReadIni AppName$, KeyName$, nDefault, DefaultStr$, ReturnStr$, Numeric%, IniFileName$
  207.  
  208.     For X = 1 To NumArrays
  209.     VirtualText.TextArray(X).FontName = ReturnStr$
  210.     Next
  211.  
  212. '*******************************
  213. '   Read the FontSize Setting
  214. '*******************************
  215.     DefaultStr$ = " "          'Default string (for String variables)
  216.     Numeric% = 0   'Tell it we are looking for a string
  217.     KeyName$ = "FontSize"    'Keyword or variable name
  218.     ReadIni AppName$, KeyName$, nDefault, DefaultStr$, ReturnStr$, Numeric%, IniFileName$
  219.  
  220.     For X = 1 To NumArrays
  221.     VirtualText.TextArray(X).FontSize = Val(ReturnStr$)
  222.     Next
  223.  
  224. '*******************************
  225. '   Read the FontBold Setting
  226. '*******************************
  227.     DefaultStr$ = " "          'Default string (for String variables)
  228.     Numeric% = 0   'Tell it we are looking for a string
  229.     KeyName$ = "FontBold"    'Keyword or variable name
  230.     ReadIni AppName$, KeyName$, nDefault, DefaultStr$, ReturnStr$, Numeric%, IniFileName$
  231.  
  232.     For X = 1 To NumArrays
  233.  
  234.     If ReturnStr$ = "YES" Then
  235.         VirtualText.TextArray(X).FontBold = True
  236.     Else
  237.         VirtualText.TextArray(X).FontBold = False
  238.     End If
  239.     Next
  240.  
  241. '**********